<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Set"%>
<%@page import="com.feib.stms.model.MenuItem"%>
<%@page import="com.feib.stms.util.UserUtil"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%
if (null != UserUtil.getUser()) {
	out.println("<ul>");

	Map menus = UserUtil.getUserMenuItems();

	if (null != menus)
	{
		MenuItem currentMenuItem = UserUtil.getCurrentMenuItem();

		Set parentMenus = menus.keySet();

		for(Iterator i = parentMenus.iterator(); i.hasNext();)
		{
			MenuItem parentItem = (MenuItem)i.next();
			MenuItem firstSubItem = null;
			Set subMenus = (Set)menus.get(parentItem);
			for(Iterator j = subMenus.iterator(); j.hasNext();)
			{
				firstSubItem = (MenuItem)j.next();
				break;
			}
			request.setAttribute("firstSubItem", null == firstSubItem ? "" : firstSubItem.getActionPage());
			
			
			out.println("<li id=\""+StringUtils.defaultIfEmpty(parentItem.getImgId(), "")+"\"> &nbsp;");
			out.println("<ul>");
			
			for(Iterator j = subMenus.iterator(); j.hasNext();)
			{
				MenuItem subMenu = (MenuItem)j.next();
				request.setAttribute("subMenu", subMenu);
				
				if (null != currentMenuItem && currentMenuItem.equals(subMenu))
					request.setAttribute("activePageClass", "now");
				else
					request.setAttribute("activePageClass", "");
%>
		<li class="<c:out value='${activePageClass}'/>"><a href="<c:url value='${subMenu.actionPage }'/>" ><c:out value='${subMenu.actionName}'/></a></li>
<%
				
			}
			
			out.println("</ul>");
			out.println("</li>");
			
			
			
		}
	}
	out.println("</ul>");
}
%>
